import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../views/Index.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Index',
    component: Index,
    redirect:'/index'
  },
  {
    path: '/index/:ph?',
    name: 'Index',
    component: () => import('../views/Index.vue'),
  },
  {
    path: '/details',
    name: 'Details',
    component: () => import('../views/Details.vue'),
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login.vue'),
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('../views/Register.vue'),
  },
  {
    path: '/car',
    name: 'Car',
    component: () => import('../views/Car.vue'),
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
  scrollBehavior(to,from,savedPosition){
    // 路由跳转时   新面试顶部浏览  而不是旧 页面原位置浏览
    return { x:0,y:0 }
  }
})

export default router
